//
//  APIbase.h
//  DoctorVideo
//
//  Created by 牛清旭 on 2019/8/13.
//  Copyright © 2019 lzx. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "AFNetworking.h"


#define NetManagerShare [APIbase sharedNetManager]

/*! 过期属性或方法名提醒 */
#define NetManagerDeprecated(instead) __deprecated_msg(instead)

/*！定义请求类型的枚举 */
typedef NS_ENUM(NSUInteger, HttpRequestType)
{
    /*! get请求 */
    HttpRequestTypeGet = 0,
    /*! post请求 */
    HttpRequestTypePost,
    /*! put请求 */
    HttpRequestTypePut,
    /*! delete请求 */
    HttpRequestTypeDelete
};

typedef NS_ENUM(NSUInteger, HttpRequestSerializer) {
    /** 设置请求数据为JSON格式*/
    HttpRequestSerializerJSON,
    /** 设置请求数据为HTTP格式*/
    HttpRequestSerializerHTTP,
};

typedef NS_ENUM(NSUInteger, HttpResponseSerializer) {
    /** 设置响应数据为JSON格式*/
    HttpResponseSerializerJSON,
    /** 设置响应数据为HTTP格式*/
    HttpResponseSerializerHTTP,
};


/*!
 *  方便管理请求任务。执行取消，暂停，继续等任务.
 *  - (void)cancel，取消任务
 *  - (void)suspend，暂停任务
 *  - (void)resume，继续任务
 */
typedef NSURLSessionTask URLSessionTask;
NS_ASSUME_NONNULL_BEGIN

@interface APIbase : NSObject

/**
 自定义请求头：httpHeaderField
 */
@property(nonatomic, strong) NSDictionary *httpHeaderFieldDictionary;


@property(nonatomic, assign) BOOL CustomRequest;




/*!
 *  获得全局唯一的网络请求实例单例方法
 *
 *  @return 网络请求类NetManager单例
 */
+ (instancetype)sharedNetManager;
+ (void)tearDown;
- (NSURLSessionDataTask* )requestWithMethod:(HttpRequestType)method
                                  URLString:( NSString *)URLString
                                 parameters:( NSDictionary *)parameters
                                       done:(void (^)(NSURLSessionDataTask  *  task ,  id responseObject))done
                                       fail:(void (^)(NSURLSessionDataTask *  task ,NSError *  error))fail;


- (NSString *)md5:(NSString *)str;

-(NSString *)dictionaryToMD5:(NSDictionary *)dict addTimesStr:(NSString *)timeStr;

- (NSString *)StringSort:(NSDictionary *)dict;

- (NSString *)dictionaryToString:(NSDictionary *)dictionary;

/* 输出http响应的状态码 */
- (NSInteger)showResponseCode:(NSURLSessionDataTask *)task;

/** 添加token或者UUID*/
//-(NSDictionary *)refineUsrWithDic:(NSDictionary *)parmDic;
@end

NS_ASSUME_NONNULL_END
